package application.view 
{
	import application.ApplicationFacade;
	import application.model.PhotoAreaProxy;
	import application.model.VO.GroupVO;
	import application.model.VO.LayoutVO;
	import application.view.viewComponent.GroupCombobox;
	import ginger.events.DataEvent;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Ning
	 */
	public class GroupMediator extends Mediator implements IMediator
	{
		public static const NAME:String = 'ChooseGroupControllerMediator';
		
		private var _photoAreaProxy:PhotoAreaProxy;
		public function GroupMediator(viewComponent:GroupCombobox) 
		{
			super(NAME, viewComponent);
			init();
		}
		private function init():void
		{
			_photoAreaProxy = facade.retrieveProxy(PhotoAreaProxy.NAME) as PhotoAreaProxy;
			groupCombobox.addEventListener(GroupCombobox.SELECT, onSelect);
		}
		private function get groupCombobox():GroupCombobox {
			return viewComponent as GroupCombobox;
		}
		override public function handleNotification(notification:INotification):void 
		{
			switch(notification.getName())
			{
				case ApplicationFacade.UPDATE_GROUP_CONFIG:
				groupCombobox.updateConfig(notification.getBody() as GroupVO);
				break;
			}
		}
		override public function listNotificationInterests():Array 
		{
			return [ApplicationFacade.UPDATE_GROUP_CONFIG];
		}
		
		//选择
		private function onSelect(evt:DataEvent):void
		{
			_photoAreaProxy.callPicDataByName(String(evt.data));
		}
	}
}